package com.igeek.dao;

import com.igeek.domain.Category;
import com.igeek.utils.DataSourceUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class CategoryDao {
    /**
     * 查询所有分类
     * @return
     * @throws SQLException
     */
    public List<Category> findAllCategory() throws SQLException {
        QueryRunner qr=new QueryRunner(DataSourceUtils.getDataSource());
        String sql="select * from category";
        return qr.query(sql,new BeanListHandler<>(Category.class));
    }
}
